package fei.yuzhi.com.loveflowers.fragment.firstpagefragment.detail.goodsdetail;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import fei.yuzhi.com.loveflowers.R;
import fei.yuzhi.com.loveflowers.bean.firstpagedetailbean.GoodsCommendListBean;
import fei.yuzhi.com.loveflowers.fragment.firstpagefragment.detail.baseinformation
        .BaseInfomationContract;
import fei.yuzhi.com.loveflowers.fragment.firstpagefragment.detail.baseinformation
        .BaseInformationPresenter;
import fei.yuzhi.com.loveflowers.utils.CustWebView;

public class GoodsDetailFragment extends Fragment implements BaseInfomationContract
        .IBaseInformationView {

    @BindView(R.id.goodsdetail_wv)
    CustWebView goodsdetailWv;
    @BindView(R.id.progressbar)
    ProgressBar progressbar;
    private String data;
    private boolean hasInited = false;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
    Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout
                .fragment_firstpage_detail_goods, null);
        Intent intent = getActivity().getIntent();
        data = intent.getStringExtra("data");
        BaseInformationPresenter presenter = new BaseInformationPresenter(this);
        presenter.getBean(data);
        initView();
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void getBeanSuccess(String goodsImageUrl, Map<String, String> mTextViewMap,
                               List<GoodsCommendListBean> commendListBeen) {
        String goodsUrl = mTextViewMap.get("goods_url");
        goodsdetailWv.loadUrl(goodsUrl);
        Log.i("tag", "--------tiaozhuang hhhhhhhhhhh------" + goodsUrl);
    }

    @Override
    public void getBeanFail(String msg) {

    }

    public void initView() {
        if (null != goodsdetailWv && !hasInited) {
            hasInited = true;
            progressbar.setVisibility(View.GONE);
        }
    }
}
